<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>内联表单</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="get" action="../server/ajaxReturn.json" data-validate="validate1" data-callBack="callback1">
                                        <div class="form-group">
                                            <label>新闻分类</label>
                                            <select name="pid" class="form-control">
                                                <option value="0">请选择</option>
                                                <option value="1">行业新闻</option>
                                                <option value="2">企业新闻</option>
                                            </select>
                                        </div>
                                        <span class="gap"></span>
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" name="audit" value="1"> 是否通过审查
                                            </label>
                                        </div>
                                        <span class="gap"></span>
                                        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>所有表单元素</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-horizontal" role="form" method="get" action="../server/ajaxReturn.json" data-validate="validate2">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">新闻标题</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="新闻标题" name="title">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">新闻分类</label>
                                            <div class="col-sm-4">
                                                <select class="form-control" name="category">
                                                    <option value="0">请选择</option>
                                                    <option value="1">1</option>
                                                    <option value="2">2</option>
                                                    <option value="3">3</option>
                                                    <option value="4">4</option>
                                                    <option value="5">5</option>
                                                </select>
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">作者</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="作者" name="author">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">是否审核通过</label>
                                            <div class="col-sm-4">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="audit" value="1" checked>通过
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="audit" value="2">未通过
                                                    </label>
                                                </div>
                                            </div>
                                            <p class="col-sm-6 help-block">如果是未通过，则此条新闻不在网站前台显示</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <div class="checkbox">
                                                    <label>
                                                        <input type="checkbox" name="remember" value="1"> 记住我
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">简介</label>
                                            <div class="col-sm-10">
                                                <textarea class="form-control"></textarea>
                                            </div>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <div class=" col-sm-12">
                                                <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>


<script>
    function validate1($from) {
        var pid = $from.find('select[name="pid"]');
        if (pid.val() == 0) {
            return '请选择分类';
        }

        return true;
    }
    function callback1(returnData, $from) {
        console.log($from);
    }
    function validate2($from) {
        var title = $from.find('input[name="title"]');
        if ($.trim(title.val()) == '') {
            return '新闻标题不能为空';
        }

        return true;
    }
</script>